<template>
  <div class="c-bg-sgray c-fs22">
    <div class="c-p">
      <div class="c-w100 c-hh240 theme-bg-gradient c-pt40 c-ph24 c-fc-gray"></div>
      <div class="c-w100 c-bg-white c-hh160"></div>
      <div class="c-pa c-p-t40 c-p-l0 c-ph30 c-w100 c-fc-gray">
        <div class="c-fs20 c-pt40 c-bg-white c-br12 c-ph30 c-box-shadow9 c-pb30">
          <div>{{companyId == 'ldwk' ? '蜜友券(可课程购买'+(!isiOSApp ? '、商城消费、VIP续费)' : ')') : '可提现金额'}}</div>
          <div class="c-flex-row c-justify-sb c-aligni-center c-pt8">
            <div class="c-fs40 c-fc-xblack">{{myIncome.balance}}</div>
            <div class="c-flex-row c-aligni-center c-ph40 c-hh48 theme-bg c-br24 c-fc-white c-fs22" v-if="!$isStore() && ((companyId == 'ldwk' && (vipType == 3 || vipType > 4)) || (companyId != 'ldwk'))" @click="goWithdraw">去提现</div>
          </div>
          <div class="c-flex-row c-justify-sb c-aligni-center c-pt20 c-pb24 c-bd-b1-f6">
            <div class="c-flex-row c-aligni-center c-fs22"><i class="iconfont c-pr10 c-fs18">&#xe642;</i>待结算{{myIncome.freezeMoney}}</div>
            <div v-if="myIncome.iosBalance">{{myIncome.iosBalance != 0 ? `不可提现${myIncome.iosBalance}` : ''}}</div>
          </div>
          <div class="c-pt20 c-flex-row c-justify-sb c-aligni-center">
            <div>
              <div>累计已结算</div>
              <div class="c-pt10 c-fs28 c-fc-xblack">{{myIncome.totalIncome}}</div>
            </div>
            <div>
              <div>今日结算</div>
              <div class="c-pt10 c-fs28 c-fc-xblack">{{myIncome.earningsToday}}</div>
            </div>
            <div>
              <div>本月结算</div>
              <div class="c-pt10 c-fs28 c-fc-xblack">{{myIncome.earningsMonth}}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="minh1600 c-p" id="detailPart">
      <div :class="[cssSupportSticky == false && isFixed ? 'tabHeight' : '', unenableTopNav ? 'c-wx-top0' : 'c']" style="visibility: hidden"></div>
      <div :class="cssSupportSticky ? ($isWxApp() || unenableTopNav || isFaShou ? 'sticky c-wx-top0' : 'sticky') : isFixed ? 'fixed c-pz100' : ''" class="c-bg-white c-w100 c-pt40" style="z-index:100">
        <div class="c-ww540 c-mlr-auto">
          <div class="c-br8 theme-bd1 c-flex-row c-aligni-center c-fs24 c-h">
            <div class="c-ww180 c-lh60 c-textAlign-c" :class="[index == 1 ? 'theme-bd-r1 theme-bd-l1' : '', tabIndex == index ? 'c-fc-white theme-bg' : 'c-fc-sblack c-bg-white', index == 0 ? 'br-tl6 br-bl6' : '', index == 2 ? 'br-tr6 br-br6' : '']" v-for="(item, index) in tablist" :key="index" @click="changeTab(index)">{{item}}</div>
          </div>
        </div>
        <div class="c-pt20 c-ph24 c-flex-row c-justify-sb c-aligni-center c-bg-white c-pb8" v-if="tabIndex == 0">
          <my-small-tabbar :tabList="settlementStatus" :tabIndex="settlementIndex" :flexClass="'c-justify-start'" :isScroll="true" @changeTab="changeType"></my-small-tabbar>
          <div class="c-flex-row c-justify-sb c-aligni-center c-p">
            <popup-picker class="c-pr10 c-ww160 bd1-f6 c-br24 c-ph20 c-pv8" :title="''" :data="isFaShou? [revenueValue]:revenueList" v-model="revenueValue" placeholder="" @on-change="changeRevenueType" value-text-align="left" @on-show="showRevenue" @on-hide="hideRevenue"></popup-picker>
            <span class="iconfont c-pl8 c-fs18 c-pa c-p-r20 c-fc-xblack">{{arrowDirection ? '&#xe6ab;' : '&#xe6a9;' }}</span>
          </div>
        </div>
        <div class="c-pt40 c-pb20 c-bg-white c-fc-xblack c-ph24" v-if="tabIndex == 1">累计提现金额: {{'￥' | iosPriceFilter}}{{myIncome.withdrawedMoney > 0 ? myIncome.withdrawedMoney : '--'}}</div>
        <div class="c-pt20 c-ph24 c-bg-white c-pb8" v-if="tabIndex == 2">
          <my-small-tabbar :tabList="isFaShou? consumeList.filter(i=>i.index==1): consumeList" :tabIndex="consumeIndex" :flexClass="'c-justify-start'" :isScroll="true" @changeTab="ChangeConsumeTab"></my-small-tabbar>
        </div>
      </div>
      <div id="box">
        <div v-if="tabIndex == 0">
          <div class="c-br10 c-ph24 c-bg-sgray c-pt20">
            <div class="c-pv20 c-bg-white c-mb20 c-br10" v-for="(item,index) in dataInfo" :key="index">
              <div class="c-flex-row c-justify-sb c-aligni-center c-ph24 c-bd-b1-f6 c-pb20" v-if="item.outType != 1 && item.outType != 2">
                <div class="c-flex-row c-aligni-center c-w0 c-flex-grow1">
                  <img :src="$addXossFilter(item.avatar, require('@/assets/defult_head.png'))" alt="" class="c-hh64 c-ww64 c-brp50">
                  <div class="c-pl8 c-w0 c-flex-grow1 c-hh64 c-flex-column c-justify-sa">
                    <div class="c-text-ellipsis1 c-maxw242 c-fc-xblack">{{item.nickname}}</div>
                    <div v-if="item.mobile" class="c-fs20 c-text-ellipsis1 c-maxw242 c-fc-gray">手机号: {{ item.mobile }}</div>
                  </div>
                </div>
                <div class="c-fc-gray">{{item.tag}}</div>
              </div>
              <div class="pt22 c-pb24 c-flex-row c-ph24">
                <div class="c-br10 c-ww180 c-hh120 c-text-hidden c-p">
                  <vip-custom-img :cover="item.vipInfo.cover" :imgClass="'imgCloseBig c-br10'" :imgShowType="'blur'" :fontClass="{
                    boxStyle: 'c-pv20 c-pl12',
                    name: 'c-fs24 c-text-ellipsis1 c-fw-b',
                    duration: 'c-fs18'}" :content="{name: item.vipInfo.name, duration: item.vipInfo.duration, durationType: item.vipInfo.durationType}" v-if="item.vipInfo && item.vipInfo.cover" />
                  <CoverImg v-else :coverUrl="getImgUrl(item)" :prodType="item.prodType" />
                  <div class="c-pa c-p-b0 c-p-l0 c-hh36 c-w100" v-if="item.refundType == 1 || item.refundType == 2">
                    <div class="c-w100 c-h c-bg-black c-opacity80 c-p"></div>
                    <div class="c-fc-white c-textAlign-c c-pa c-p-l0 c-p-t0 c-w100 c-h c-lh36">{{item.refundType == 1 ? '全额退款' : '部分退款'}}</div>
                  </div>
                </div>
                <div class="c-w0 c-flex-grow1 c-pl20">
                  <div class="c-fs26 c-fw-b c-text-ellipsis1 c-fc-xblack">{{item.prodName}}</div>
                  <div class="c-flex-row c-aligni-center c-pt12">
                    <span class="c-pr10 c-fc-gray">到账：{{incomeDestMap[item.dest]}}</span>
                  </div>
                  <div class="c-pt12 c-fc-gray" v-if="item.createdAt && !item.outType">创建时间: {{item.createdAt}}</div>
                  <div class="c-pt12 c-fc-gray" v-if="settlementIndex == 1">
                    <div v-if="item.outType == 1 || item.outType == 2">{{item.outType == 1 ? '中奖时间' : '领取时间'}}: {{item.createdAt}}</div>
                    <div v-else>结算时间: {{item.finishAt}}</div>
                  </div>
                </div>
              </div>
              <div v-if="item.outType == 1 ||item.outType == 2" class="c-ph20">
                <div class="c-pt20 bd-t1f6 c-flex-row c-justify-sb c-aligni-center c-fc-gray">
                  <span >{{item.outType == 1 ? '直播抽奖':'直播福利'}}</span>
                  <span class="theme-fc c-pl6 c-pr10">{{'￥' | iosPriceFilter}}{{item.amount}}</span>
                </div>
              </div>
              <div v-else class="c-ph20">
                <div class="c-pt20 bd-t1f6 c-flex-row c-justify-sb c-aligni-center c-fc-gray">
                  <div class="c-fc-gray">购买{{typeMap[item.prodType]}}</div>
                  <div class="c-flex-row c-justify-sb">
                    <div>实付{{'￥' | iosPriceFilter}}{{item.payMoney}}</div>
                    <div class="c-pl10">{{(item.type == 88 || item.type == 120 || item.type == 188) ? '退款' : '推广收益'}}<span class="theme-fc c-pl6 c-pr10">{{'￥' | iosPriceFilter}}{{item.amount}}</span></div>
                  </div>
                </div>
              </div>
            </div>
            <loading-status-tem :noData="noneShow" :noMoreData="loadingStatus == 'NO_MORE_DATA' && !noneShow" :noDataText="'暂无相关明细'" :showLoading="isLoading">
            </loading-status-tem>
          </div>
        </div>
        <div v-if="tabIndex == 1">
          <div v-for="(item,index) in dataInfo" :key="index" class="c-bg-sgray c-ph24">
            <div v-if="index == 0" class="c-pt20">
              <span class="c-fc-xblack"><span class="c-fs40 c-fw-b">{{dataInfo[0].month | filtersMonth}}</span><span class="c-pl8 c-pr5">/</span><span class="c-fs22">{{dataInfo[0].month | filtersYear}}</span></span>
              <span class="c-pl24">提现{{dataInfo[0].monthAmount}}</span>
            </div>
            <div v-if="index > 0 && !(item.month == dataInfo[index-1].month)" class="c-pt20">
              <span class="c-fc-xblack"><span class="c-fs56 c-fw-b">{{item.month | filtersMonth}}</span><span class="c-pl8 c-pr5">/</span><span class="c-fs22">{{item.month | filtersYear}}</span></span>
              <span class="c-pl24">提现{{item.monthAmount}}</span>
            </div>
            <div :class="index == 0 ? 'c-pt12' : 'c-pt20'">
              <div class="c-pt20 c-pb24 c-bg-white c-br10">
                <div class="c-flex-row c-justify-sb c-aligni-center c-pb20 c-ph20">
                  <div class="c-flex-row c-aligni-center">
                    <div class="c-ww56 c-hh56 c-text-hidden">
                      <img v-if="item.dest == 1" :src="require('../../../assets/i/wap/voting/bank.png')" class="c-ww56 c-hh56 c-brp50" />
                      <span v-else-if="item.dest == 3" class="iconfont c-fs52 c-fc-smblue">&#xe74e;</span>
                      <span v-else class="iconfont c-fs52 c-fc-green">&#xe928;</span>
                    </div>
                    <div class="c-fs24 c-pl16">提现到{{item.dest==1 ? '银行卡' : item.dest==3 ? '支付宝' : '微信'}}</div>
                  </div>
                  <div class="c-fs32 c-lh c-textAlign-r c-fc-xblack"><span class="c-fs20">{{'￥' | iosPriceFilter}}</span>{{item.amount}}</div>
                </div>
                <div class="c-pt20 bd-t1f6 c-fc-gray c-fs20 c-ph20">
                  <div>明细:<span class="c-pl10">提现{{(Number(item.amount) + Number(item.fee)).toFixed(2)}}元, 手续费{{item.fee}}元</span></div>
                  <div class="c-pt16">申请时间:<span class="c-pl10">{{item.createdAt}}</span></div>
                  <div class="c-flex-row c-aligni-center c-hh48 c-mt6">
                    <div class="c-w0 c-flex-grow1"><span class="c-fc-gray">提现状态:</span><span class="c-pl10" :class="item.status == -1 ? 'c-fc-xmlred' : item.status == 2 ? 'c-fc-xblack' : 'c-fc-green'">{{withdrawStatus(item)}}</span></div>
                    <div v-if="item.isUseWxNewTransfer == 1 && item.status == 4" @click="clickReceive(item)" class="c-fs22 c-fc-white c-hh48 c-ww110 c-br24 c-flex-row c-flex-center theme-bg">去确认</div>
                  </div>
                  <count-line-height :item = "item" v-if="item.status == -1"></count-line-height>
                </div>
              </div>
            </div>
          </div>
          <loading-status-tem :noData="noneShow" :noMoreData="loadingStatus == 'NO_MORE_DATA' && !noneShow" :noDataText="'暂无相关提现记录'" :showLoading="isLoading">
          </loading-status-tem>
        </div>
        <div v-if="tabIndex == 2">
          <div class="c-ph24 c-bg-sgray c-pt20">
            <div class="c-br10 c-pv20 c-ph24 c-bg-white c-mb20" v-for="(item, index) in dataInfo" :key="index">
              <div class="c-flex-row">
                <div class="c-ww180 c-hh120 c-br10">
                  <img class="c-w100 c-hh120 c-br10" :src="$addXossFilter((item.img || item.cionImg), DEFAULT_IMG_MAP[item.prodType] || require('@/assets/defult270.png') )" alt="" />
                </div>
                <div class="c-pl20 c-w0 c-flex-grow1">
                  <div class="c-text-ellipsis1 c-fc-xblack c-fs26 c-fw-b">{{consumeIndex == 3 ? item.name : item.prodName}}</div>
                  <div v-if="consumeIndex == 3" class="c-pt12 c-fc-gray">支付方式: {{item.payType == 14 ? '虚拟币支付' : item.payType==1?'微信支付':item.payType==20?'支付宝支付':'余额支付'}}</div>
                  <div v-else class="c-pt12 c-fc-gray">支付方式: {{item.paymentMethod == 14 ? '虚拟币支付' : item.paymentMethod==1?'微信支付':item.paymentMethod==20?'支付宝支付':item.paymentMethod==4?'线下支付':item.paymentMethod==17?'先学后付':'余额支付'}}</div>
                  <div class="c-pt12 c-fc-gray">{{consumeIndex == 3 ? '充值' : '消费'}}时间: {{item.createdAt}}</div>
                  <div class="c-pt12 c-fc-gray">{{consumeIndex == 3 ? '充值' : '消费'}}金额: <span class="theme-fc">{{'￥' | iosPriceFilter}}{{consumeIndex == 3 ? item.changeMoney : item.amount || '0.00'}}</span></div>
                  <div class="c-pt12 c-fc-gray" v-if="item.paymentMethod == 4 && item.offlinePayMoney">线下实付: <span class="theme-fc">￥{{Number(item.offlinePayMoney).toFixed(2)}}</span></div>
                </div>
              </div>
            </div>
          </div>
          <loading-status-tem :noData="noneShow" :noMoreData="loadingStatus == 'NO_MORE_DATA' && !noneShow" :noDataText="'暂无相关消费记录'" :showLoading="isLoading">
          </loading-status-tem>
        </div>
      </div>
    </div>
    <div v-if="withdrawSettings && withdrawSettings.isSubMchId == 1 && (withdrawSettings.isNeedInvoice == 1 || withdrawSettings.isNeedInvoice == 2)" @click="goTaxList" class="c-pf c-p-b140 c-p-r0 c-fs20 c-fw600 c-fc-white c-ww124 c-hh44 c-flex-row c-flex-center c-br-tl32 c-br-bl32 theme-bg">发票与税额</div>
    <cj-popup v-model="showSubmitNamePopup" position="center" class="c-w80" round>
      <div class="c-bg-white c-flex-column c-br20 c-fc-xblack">
        <div class="c-ph40 c-textAlign-c c-pb40 c-p">
          <div class="c-fs28 c-fw600 c-pt40 c-pb20">验证收款人姓名</div>
          <div class="c-fs22 c-lh36 c-pb10">微信规定，提现金额大于等于2000元，需实名认证。请填写本微信号实名认证的完整姓名，否则会打款失败。</div>
          <div :class="showInputError ? 'c-bd-b1-xxlred' : 'c-bd-b1-ccc'">
            <input @input="inpurEnter" @focus='inputFocus' @blur='inputBlur' id="inputName" type="text" v-model.trim="inputName" class="c-bd0 c-w100 c-hh70 c-fs28 c-textAlign-c" />
          </div>
          <div v-show="showInputError" class="c-fs18 c-fc-xxlred c-pa c-p-b10">请输入收款人姓名</div>
        </div>
        <div class="c-hh78 c-bd-t1 c-flex-row c-fs28">
          <div @click="closeSubmitNamePopup" class="c-flex-1 c-bd-r1 c-flex-row c-flex-center c-fc-gray">取消</div>
          <div @click="clickSubmitName" class="c-flex-1 c-flex-row c-flex-center theme-fc">确认</div>
        </div>
      </div>
    </cj-popup>
  </div>
</template>


<script>
import loadingStatusTem from "@/components/templates/common/loadingStatusTem.vue";
import MySmallTabbar from "@/components/templates/common/MySmallTabbar.vue";
import { utilJs } from "@/utils/common.js"
import CountLineHeight from "@/components/templates/countLineHeight.vue"
import CoverImg from '@/components/templates/common/coverImg.vue';
import VipCustomImg from "@/components/templates/common/VipCustomImg.vue";
import { PopupPicker } from 'ckjrweb-mp-ui/src/components/index';
import { DEFAULT_IMG_MAP } from "@/utils/constant.js";
let mallIndex = 1; //商城消费页码
let withdrawItem = null
let inputScrollTop = 0;
export default {
  name: 'ScholarshipIndex',
  components: {
    MySmallTabbar,
    loadingStatusTem,
    CountLineHeight,
    CoverImg,
    PopupPicker,
    VipCustomImg
  },
  props: [],
  beforeCreate() {

  },
  data() {
    return {
      isFaShou: localStorage.getItem("isFaShou") == 1,
      DEFAULT_IMG_MAP:DEFAULT_IMG_MAP,
      isiOSApp: false,
      myIncome: '',
      vipType: localStorage.getItem("vipType" + localStorage.getItem("userId")),
      companyId: localStorage.getItem("companyId"),
      tablist: ['收入明细', '提现记录', '消费记录'],
      tabIndex: 0,
      settlementStatus: [{
        title: '已结算',
        index: 1,
      }, {
        title: '待结算',
        index: 2,
      }],
      settlementIndex: 1, //已(待)结算索引
      typeBar: 1,
      arrowDirection: false,
      revenueValue: ["知识收入"],
      revenueList: [["知识收入", "推广收入", "红包收入"]],
      revenueIndex: 1, //1知识收入, 2推广收入, 3红包收入
      timeType: 0, //0:总计
      pageSize: 15,
      dataInfo: [],
      noneShow: false,
      loadingStatus: "NO_MORE_DATA",
      OFFICE_TYPE: ["doc", "docx", "pdf", "ppt", "pptx", "xls", "xlsx"],
      IMG_TYPE: [
        "bmp",
        "jpg",
        "png",
        "gif",
        "svg",
        "psd",
        "webp",
        "jpeg",
        "eps",
        "tga",
        "tiff"
      ],
      AUDIO_TYPE: [
        "ogg",
        "mp3",
        "wav",
        "asf",
        "wma",
        "mp3pro",
        "real",
        "ape",
        "module",
        "midi",
        "vqf"
      ],
      VIDEO_TYPE: [
        "avi",
        "wmv",
        "mpeg",
        "asf",
        "mpg",
        "dv",
        "rm",
        "rmvb",
        "mod",
        "flv",
        "mp4",
        "qt",
        "divx",
        "mkv",
        "vob"
      ],
      cfrom: global.ckFrom,
      incomeDestMap:{
        1: '账户余额',
        2: '微信余额',
        10: '账户余额',
        20: '分账中',
        30: '视频号账户'
      },
      typeMap: global.prodMapType,
      isLoading: false,
      consumeList: [
        {
          title: '知识消费',
          index: 1,
        },
        {
          title: '商城消费',
          index: 2,
        },
        {
          title: '充值消费',
          index: 3,
        }
      ],
      consumeIndex: 1,
      widthdrawIndex: 1,
      learningIndex: 1, //知识消费页码
      mallLimit: 10,
      isFixed: false, //是否吸顶
      cssSupportSticky: false,
      companyAuth: JSON.parse(localStorage.getItem("companyAuth")),
      showSubmitNamePopup: false, // 显示提交验证收款人姓名弹窗
      inputName: '', // 收款人姓名
      showInputError: false, // 未填写收款人姓名提示
      withdrawSettings: null
    }
  },
  created() {

  },
  mounted() {
    if ((window.CSS && window.CSS.supports) || window.supportsCSS) {
      // 该方法可以判断不同内核的兼容性,较为准确
      this.cssSupportSticky = CSS.supports("(position: sticky) or (position: -webkit-sticky)");
    } else {
      // 自定义方法虽然能判断样式是否兼容，无法判断不同内核是否可以使用
      this.cssSupportSticky = this.cssSupport('position', 'sticky');
    }
  },
  watch: {

  },
  filters: {
    filtersMonth(value) {
      if (value != undefined && value != "" && value != null) {
        return value.substr(5, 2);
      }
    },
    filtersYear(value) {
      if (value != undefined && value != "" && value != null) {
        return value.substr(0, 4);
      }
    }
  },
  computed: {
  // 判断是否有顶部导航
    unenableTopNav() {
      return this.companyAuth && this.companyAuth.companyTopNav && this.companyAuth.companyTopNav.style && this.companyAuth.companyTopNav.style == 5
    },
  },
  methods: {
    getImgUrl(item) {
      if (item.prodType == this.cfrom.shareholderPayVoucher) {
        return require('@/assets/shareholderPayVoucher.png')
      } else if (item.vipInfo && item.vipInfo.cover) {
        return item.vipInfo
      } else {
        return item.img
      }
    },
    withdrawStatus(withDrawItem) {
      if (withDrawItem.isUseWxNewTransfer == 1 && withDrawItem.status == 4) {
        return '确认收款'
      } else if (withDrawItem.status == -1) {
        return '已驳回'
      } else if (withDrawItem.status == 2) {
        return '已通过'
      } else {
        return '审核中'
      }
    },
    inpurEnter() {
      if (this.inputName) {
        this.showInputError = false;
      }
    },
    //IOS微信6.7以上版本会导致输入法收起的时候，键盘没收起，需要手动滚下屏幕
    inputFocus() {
      if (navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        inputScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
      }
    },
    inputBlur() {
      if (navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        setTimeout(() => {
          document.body.scrollTop = inputScrollTop - 1 || 0;
        });
      }
    },
    clickSubmitName() {
      this.inputName = this.inputName.replace(/\s*/g, ""); // 去掉所有空格
      if (!this.inputName) {
        this.showInputError = true;
      } else {
        this.receivePayment()
      }
    },
    closeSubmitNamePopup() {
      this.inputName = '';
      this.showInputError = false;
      this.showSubmitNamePopup = false;
    },
    clickReceive(wItem) {
      if (!utilJs.isWeiXin() || this.$isWxApp()) {
        this.$showCjToast({
          text: "请在微信公众号中确认收款",
          type: 'text',
        });
        return
      }
      withdrawItem = wItem
      if (!this.checkSubmit(wItem)) {
        this.showSubmitNamePopup = true;
      } else {
        this.receivePayment();
      }
    },
    checkSubmit(wItem) {
      if ((Number(wItem.amount) + Number(wItem.fee)) >= 2000 && !this.inputName) {
        // 提现金额大于等于2000 && 没有输入收款人姓名
        return false;
      } else {
        return true;
      }
    },
    receivePaymentCallBack() {
      this.$cjConfirm({
        title: '提现成功',
        message: '提现成功，请及时查收',
        showCancelButton:false,
        confirmButtonText:'我知道了',
        onConfirm:() => {
          location.reload();
        },
      })
    },
    receivePayment() {
      if (!withdrawItem) {
        return
      }
      this.$loading.show();
      let postData = {
        wId: withdrawItem.wId
      };
      if ((Number(withdrawItem.amount) + Number(withdrawItem.fee)) >= 2000 && this.inputName) {
        postData.inputName = this.inputName
      }
      utilJs.postMethod(global.apiurl + 'wxTransferBills/transferBills', postData, res => {
        if (res.state == 'WAIT_USER_CONFIRM') {
          let transferData = {
            appId: res.appId,
            mchId: res.mchId,
            package: res.packageInfo
          }
          utilJs.wxReceivePayment(transferData, this.receivePaymentCallBack);
        }
        this.inputName = '';
        this.showInputError = false;
        this.showSubmitNamePopup = false;
        this.$loading.hide();
      });
    },
    goTaxList() {
      this.$routerGo(this, "push", { path: '/member/scholarship/taxList' });
    },
    getWithdrawSettings() {
      utilJs.getMethod(`${global.apiurl}common/getWithdrawSettings`, res => {
        this.withdrawSettings = res;
      })
    },
    // 判断样式是否被兼容
    cssSupport: function (attr, value) {
      let element = document.createElement('div');
      if (attr in element.style) {
        element.style[attr] = value;
        return element.style[attr] === value;
      } else {
        return false;
      }
    },
    goWithdraw: function () { // 已体现
      this.$routerGo(this, "push", { path: '/member/scholarship/withdraw', query: { from: 'bank', noDefault: 1 } });
    },
    //收入明细、提现记录、消费记录
    changeTab(index) {
      this.tabIndex = index;
      this.settlementIndex = 1;
      this.revenueIndex = 1;
      this.consumeIndex = 1;
      this.revenueValue = ["知识收入"];
      this.learningIndex = 1;
      mallIndex = 1;
      this.dataInfo = [];
      this.loadingStatus = "NO_MORE_DATA";
      if (index == 2 && this.consumeIndex == 2) {
        this.getmallList();
      } else {
        this.getRecordListList();
      }
      this.$nextTick(() => {
        if (this.isFixed) {
          window.scrollTo(0, 220);
        }
      })
    },
    // 已结算、待结算
    changeType(type) {
      this.settlementIndex = type;
      this.learningIndex = 1;
      this.dataInfo = [];
      this.getRecordListList();
      this.$nextTick(() => {
        if (this.isFixed) {
          window.scrollTo(0, 220);
        }
      })
    },
    // 切换知识、推广、红包收入
    changeRevenueType(value) {
      if (value[0] == '知识收入') {
        this.revenueIndex = 1;
      } else if (value[0] == '推广收入') {
        this.revenueIndex = 2;
      } else {
        this.revenueIndex = 3;
      }
      this.arrowDirection = !this.arrowDirection;
      this.learningIndex = 1;
      this.dataInfo = [];
      this.getRecordListList();
      this.$nextTick(() => {
        if (this.isFixed) {
          window.scrollTo(0, 220);
        }
      })
    },
    //知识消费、商城消费
    ChangeConsumeTab(index) {
      this.consumeIndex = index;
      this.dataInfo = [];
      this.tabIndex = 2;
      this.learningIndex = 1;
      mallIndex = 1;
      if (index == 1 || index == 3) {
        this.getRecordListList()
      } else {
        this.getmallList()
      }
      this.$nextTick(() => {
        if (this.isFixed) {
          window.scrollTo(0, 220);
        }
      })
    },
    // 获取知识消费记录
    getRecordListList() {
      if (!this.isLoading) {
        this.isLoading = true;
        let url = this.tabIndex == 1 ? 'members/widthdrawLogs?page=' : (this.tabIndex == 0 ? `members/getIncomeDetailList?timeType=${this.timeType}&status=${this.settlementIndex}&type=${this.revenueIndex}&page=` : (this.consumeIndex == 3 ? 'giftCard/giftCardRechargeLog?page=' : 'members/consumeLogs?page='))
        utilJs.getMethod(global.apiurl + url + this.learningIndex + '&limit=' + this.pageSize, res => {
          this.isLoading = false;
          if (this.learningIndex == 1) {
            this.dataInfo = res.data;
          } else {
            this.dataInfo = [...this.dataInfo, ...res.data];
          }
          if (this.dataInfo.length == 0) {
            this.noneShow = true;
            this.loadingStatus = "NO_MORE_DATA";
          } else {
            this.noneShow = false;
          }
          if (res.data && res.data.length < this.pageSize) {
            this.loadingStatus = this.learningIndex == 1 && res.data.length == 0 ? 'NO_DATA' : 'NO_MORE_DATA';
          } else {
            this.loadingStatus = 'HAS_MORE_DATA';
            this.learningIndex++;
          }
          this.isLoading = false;
        });
      }
    },
    // 获取商城消费记录
    getmallList() {
      if (!this.isLoading) {
        this.isLoading = true;
        utilJs.getMethod(`${global.apiurl}members/mallConsumeLogs?page=${mallIndex}&limit=${this.mallLimit}`, res => {
          this.isLoading = false;
          if (mallIndex == 1) {
            this.dataInfo = res.data;
          } else {
            this.dataInfo = [...this.dataInfo, ...res.data];
          }
          if (this.dataInfo.length == 0) {
            this.noneShow = true;
            this.loadingStatus = "NO_MORE_DATA";
          } else {
            this.noneShow = false;
          }
          if (res.data && res.data.length < this.mallLimit) {
            this.loadingStatus = mallIndex == 1 && res.data.length == 0 ? 'NO_DATA' : 'NO_MORE_DATA';
          } else {
            this.loadingStatus = 'HAS_MORE_DATA';
            mallIndex++;
          }
          this.isLoading = false;
        });
      }
    },
    showRevenue() {
      this.arrowDirection = true;
    },
    hideRevenue() {
      this.arrowDirection = false;
    },
    scrollToConfirm() {
      let detailPartTop = document.getElementById('detailPart').offsetTop;
      window.scrollTo({
        top: detailPartTop,
        behavior: 'smooth'
      })
    },
    //分享
    wechatShare: function () {
      utilJs.wechatConfig("", "", "", "", function () { });
    },
    windowScrollFunction: function () {
      let that = this;
      utilJs.handleLoading(() => {
        if (that.loadingStatus == 'HAS_MORE_DATA') {
          if (that.tabIndex == 2 && that.consumeIndex == 2) {
            that.getmallList();
          } else {
            that.getRecordListList();
          }
        }
      })
    },
    windowScroll() {
      let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
      if (scrollTop > 220) {
        this.isFixed = true;
      } else {
        this.isFixed = false;
      }
    }
  },
  activated() {
    //为了iosAPP审核通过
    this.isiOSApp = navigator.userAgent.indexOf('IOSLogin') > -1 || navigator.userAgent.indexOf('IOSNewLogin') > -1 || navigator.userAgent.indexOf("IOSNewApp") > -1;
    // 获取我的收益数据
    setDocumentTitle("我的账户");// eslint-disable-line
    this.typeBar = 1;
    this.arrowDirection = false;
    this.isFixed = false;
    this.revenueValue = ["知识收入"];
    this.revenueIndex = 1;
    this.timeType = 0;
    this.settlementIndex = 1;
    this.consumeIndex = this.$route.query.consumeIndex || 1;
    this.widthdrawIndex = 1;
    this.learningIndex = 1;
    mallIndex = 1;
    this.dataInfo = [];
    this.noneShow = false;
    this.loadingStatus = "NO_MORE_DATA";
    this.isLoading = false;
    this.showSubmitNamePopup = false;
    this.inputName = '';
    this.showInputError = false;
    this.typeMap = global.prodMapType;
    this.typeMap[global.ckFrom.qa] = localStorage.getItem("questionCustom") == 1 ? "预约专区" : "付费问答";
    this.typeMap[global.ckFrom.answer] = localStorage.getItem("questionCustom") == 1 ? "预约专区" : "付费问答";
    this.typeMap[global.ckFrom.circusee] = localStorage.getItem("questionCustom") == 1 ? "围观预约" : "围观问题";
    this.typeMap[global.ckFrom.agentApply] = JSON.parse(localStorage.getItem("customName")).agentName;
    this.typeMap[global.ckFrom.partnerApply] = JSON.parse(localStorage.getItem("customName")).partnerName;
    this.typeMap[global.ckFrom.branchApply] = JSON.parse(localStorage.getItem("customName")).branchName;
    this.typeMap[global.ckFrom.cooApply] = JSON.parse(localStorage.getItem("customName")).cooName;
    this.typeMap[global.ckFrom.agencyApply] = JSON.parse(localStorage.getItem("customName")).agencyName;
    this.typeMap[global.ckFrom.agent6Apply] = JSON.parse(localStorage.getItem("customName")).agent6Name;
    this.typeMap[global.ckFrom.agent7Apply] = JSON.parse(localStorage.getItem("customName")).agent7Name;
    this.typeMap[global.ckFrom.agent8Apply] = JSON.parse(localStorage.getItem("customName")).agent8Name;
    this.typeMap[global.ckFrom.agent9Apply] = JSON.parse(localStorage.getItem("customName")).agent9Name;
    utilJs.getGiftCardInfo().then(res => {
      this.typeMap[global.ckFrom.giftCard] = res.name || '虚拟币';
    })
    let $this = this;
    this.tabIndex = this.$route.query.tabIndex || 0
    utilJs.getMethod(global.apiurl + 'members/myIncome', function (res) {
      let isDistribution = JSON.parse(localStorage.getItem("companyAuth")).enableDistributionMarketModule;
      let info = res.data;
      if (isDistribution && res.distributionAmount && res.distributionAmount.length > 0) {
        info.balance = (res.data.balance * 1 + res.data.distributionBalance * 1).toFixed(2);
        info.iosBalance = res.data.iosBalance ? (res.data.iosBalance * 1).toFixed(2) : 0;
        info.totalIncome = (res.data.totalIncome * 1 + res.distributionAmount[0].distributionAmountTotal * 1).toFixed(2);
        info.earningsToday = (res.data.earningsToday * 1 + res.distributionAmount[0].distributionAmountToday * 1).toFixed(2);
        info.earnings7d = (res.data.earnings7d * 1 + res.distributionAmount[0].distributionAmountWeek * 1).toFixed(2);
      }
      $this.myIncome = info;
      if (info.confirmWithdrawNumber && info.confirmWithdrawNumber > 0) {
        $this.tabIndex = 1;
        setTimeout(() => {
          $this.$cjConfirm({
            title: '待确认收款',
            message: '存在待确认收款的提现记录',
            showCancelButton:false,
            confirmButtonText:'去确认',
            onConfirm:() => {
              $this.scrollToConfirm();
            },
          })
        }, 300);
      }
      $this.getRecordListList();
    });
    // this.getRecordListList();
    this.getWithdrawSettings();
    this.wechatShare();
    window.addEventListener('scroll', this.windowScrollFunction);
    window.addEventListener('scroll', this.windowScroll);
  },
  deactivated() {
    this.loadingStatus = 'NO_MORE_DATA';
    window.removeEventListener('scroll', this.windowScrollFunction);
    window.removeEventListener('scroll', this.windowScroll);
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.c-bg-liner-change {
  background: -o-linear-gradient(-90deg, #ff8920, #ffffff);
  background: -ms-linear-gradient(-90deg, #ff8920, #ffffff);
  background: -moz-linear-gradient(-90deg, #ff8920, #ffffff);
  background: -webkit-linear-gradient(-90deg, #ff8920, #ffffff);
}
.incomeBox {
  width: calc(100% - 1.2rem);
}
.bd1-f6{border:1px solid #F6F6F6;}
.bd-t1b1{
  border-top: 1px solid #F6F6F6;
  border-bottom: 1px solid #F6F6F6;
}
.pt22{padding-top: 0.55rem;}
.bd-t1f6{border-top:1px solid #F6F6F6;}
.vux-cell-box >>> .vux-popup-picker-value {
  color: #333 !important;
}
.br-tl6{border-top-left-radius: 0.15rem}
.br-bl6{border-bottom-left-radius: 0.15rem}
.br-tr6{border-top-right-radius: 0.15rem}
.br-br6{border-bottom-right-radius: 0.15rem}
.minh1600{min-height: 40rem;}
.tabHeight {
  height: 52px;
}
.sticky {
  position: sticky;
  position: -webkit-sticky;
  top: 1.4rem;
}
.fixed {
  position: fixed;
  width: 100%;
  top: 0;
}
</style>
